package com.biostime.springdraw.modules.sd.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.biostime.springdraw.common.persistence.Page;
import com.biostime.springdraw.common.service.CrudService;
import com.biostime.springdraw.modules.sd.dao.AwardDao;
import com.biostime.springdraw.modules.sd.entity.Award;

/**
 * 奖品表Service
 * @author king
 * @version 2016-01-18
 */
@Service
@Transactional
public class AwardService extends CrudService<AwardDao, Award> {
	@Override
	public Page<Award> findPage(Page<Award> page, Award entity) {
		entity.setPage(page);
		page.setList(findList(entity));
		return page;
	}
	
	@Override
	public List<Award> findList(Award entity) {
		return dao.findList(entity);
	}
	
	public int deleteAward(String ids){
		List<Integer> list = new ArrayList<Integer>();
		String array[] = ids.split(",");
		if(array !=null && array.length  !=0){
			for(int i=0;i<array.length;i++){
				list.add(Integer.parseInt(array[i])); 
			}
		}else{
			list.add(0);
		}
		return dao.deleteAward(list);
	}

	public boolean lockAward(Award award) {
		return dao.lockAward(award);
	}
	
}
